package unit3;

public class Ex3_5_BoxDemo2 {
    public static void main(String[] args) {
        Box2 mybox1 = new Box2(10, 20, 15);
        Box2 mybox2 = new Box2(3, 6, 9);
        double vol1, vol2;
        vol1 = mybox1.volume();
        vol2 = mybox2.volume();
        System.out.println("mybox1的体积是： " + vol1);
        System.out.println("mybox2的体积是： " + vol2);
    }
}
class Box2 { //定义Box2类
    double lenth;
    double width;
    double height;
    Box2(double l, double w, double h) { //定义带参数构造函数Box()
        lenth = l;
        width = w;
        height = h;
    }

    double volume() { // 定义计算长方体体积的方法
        return lenth * width * height;
    }
}
